package com.skynet.amqp.perfect;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.time.Duration;

@ConfigurationProperties(prefix = "amqp-prefect")
public class RetryCacheProperties {

    private boolean enabled = false;

    private final Retry retry = new Retry();

    public static class Retry {
        /* 重试过期时间（毫秒）：超时则从缓存中移除消息，避免消息拥堵，默认 120秒*/
        public Duration retryExpire = Duration.ofMillis(120000);

        /* 重试延迟时间（毫秒）：超过延迟时间的消息将进行重试，默认 60秒*/
        public Duration retryDelay = Duration.ofMillis(60000);

        /* 重试间隔时间（毫秒）：消息重试的间隔时间，越短则消息重试的次数越频繁，默认 30秒 */
        public Duration retryInterval = Duration.ofMillis(30000);

        /* 是否开启重试机制 */
        public boolean retryEnabled = true;

        public Duration getRetryExpire() {
            return retryExpire;
        }

        public void setRetryExpire(Duration retryExpire) {
            this.retryExpire = retryExpire;
        }

        public Duration getRetryDelay() {
            return retryDelay;
        }

        public void setRetryDelay(Duration retryDelay) {
            this.retryDelay = retryDelay;
        }

        public Duration getRetryInterval() {
            return retryInterval;
        }

        public void setRetryInterval(Duration retryInterval) {
            this.retryInterval = retryInterval;
        }

        public boolean isRetryEnabled() {
            return retryEnabled;
        }

        public void setRetryEnabled(boolean retryEnabled) {
            this.retryEnabled = retryEnabled;
        }
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public Retry getRetry() {
        return retry;
    }
}
